/*  1:   */ package nl.siegmann.epublib.bookprocessor;
/*  2:   */ 
/*  3:   */ import java.util.ArrayList;
/*  4:   */ import java.util.List;
/*  5:   */ import nl.siegmann.epublib.domain.Book;
/*  6:   */ import nl.siegmann.epublib.domain.Resource;
/*  7:   */ import nl.siegmann.epublib.domain.Spine;
/*  8:   */ import nl.siegmann.epublib.domain.SpineReference;
/*  9:   */ import nl.siegmann.epublib.epub.BookProcessor;
/* 10:   */ import org.apache.commons.lang.StringUtils;
/* 11:   */ 
/* 12:   */ public class SectionHrefSanityCheckBookProcessor
/* 13:   */   implements BookProcessor
/* 14:   */ {
/* 15:   */   public Book processBook(Book book)
/* 16:   */   {
/* 17:24 */     book.getSpine().setSpineReferences(checkSpineReferences(book.getSpine()));
/* 18:25 */     return book;
/* 19:   */   }
/* 20:   */   
/* 21:   */   private static List<SpineReference> checkSpineReferences(Spine spine)
/* 22:   */   {
/* 23:29 */     List<SpineReference> result = new ArrayList(spine.size());
/* 24:30 */     Resource previousResource = null;
/* 25:31 */     for (SpineReference spineReference : spine.getSpineReferences()) {
/* 26:32 */       if ((spineReference.getResource() != null) && (!StringUtils.isBlank(spineReference.getResource().getHref())))
/* 27:   */       {
/* 28:36 */         if ((previousResource == null) || (spineReference.getResource() == null) || (!spineReference.getResource().getHref().equals(previousResource.getHref()))) {
/* 29:39 */           result.add(spineReference);
/* 30:   */         }
/* 31:41 */         previousResource = spineReference.getResource();
/* 32:   */       }
/* 33:   */     }
/* 34:43 */     return result;
/* 35:   */   }
/* 36:   */ }


/* Location:           C:\Users\David\workspace\CosaRaraPorqueSi\main\epublib-tools-3.1.jar
 * Qualified Name:     nl.siegmann.epublib.bookprocessor.SectionHrefSanityCheckBookProcessor
 * JD-Core Version:    0.7.0.1
 */